<?php

#<editor-fold defaultstate="collapsed" desc="CCore::Using">
CCore::Using('base.constants');
CCore::Using('logger.inc.abstract');
#</editor-fold>

class CCoreLoggerFile extends ACoreLogger
{
	#<editor-fold defaultstate="collapsed" desc="private">
	/**
	 * @var	string
	 */
	private $_sLoggerFileName;
	#</editor-fold>

	/**
	 * @param	string	$sLoggerFileName
	 * @return	CCoreLoggerFile
	 */
	public function __construct($sLoggerFileName)
	{
		CCore::CheckTypes(array('$sLoggerFileName'));

		$this->_sLoggerFileName = $sLoggerFileName;
	}
	
	/**
	 * @param	string	$sErrorDesc
	 * @return	bool
	 */
	protected function writeImplementation($sErrorDesc)
	{
		CCore::CheckTypes(array('$sErrorDesc'));
		
		return @error_log($sErrorDesc.C_CRLF, 3, $this->_sLoggerFileName);
	}

	/**
	 * @param	string	$sTimePrefix
	 * @param	string	$sErrorDesc
	 * @return	string
	 */
	protected function logLineImplementation($sTimePrefix, $sErrorDesc)
	{
		CCore::CheckTypes(array('$sTimePrefix', '$sErrorDesc'));
		
		return '['.$sTimePrefix.'] '.$sErrorDesc;
	}

	/**
	 * @return	bool
	 */
	protected function clearImplementation()
	{
		return @unlink($this->_sLoggerFileName);
	}
}
